<?php
$packages = Package::instance()->get(array('status'=> 1, 'type'=> 'vps'));
Table::instanceTable('Price')->joinTo('prices', 'packageId', 'id', $packages, Table::JOIN_MANY);

foreach ($packages as $keyPackage => $package){
	foreach ($package['prices'] as $keyPrice => $price){
		if($price['month'] == 1){
			$packages[$keyPackage]['pricePerMonth'] = $price['price'];
			$packages[$keyPackage]['pricePerMonth'] = number_format($price['price']).' บาท';
			break;
		}
	}
	if(!isset($packages[$keyPackage]['pricePerMonth'])){
		$packages[$keyPackage]['pricePerMonth'] = '-';
	}
}
View::display('vps', array('packages'=> $packages));